package com.lm.activiti.boot.cases.thread;

import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

/**
 * @author lm_jcf
 * @date 2022/2/23 20:05
 */
public class ThreadPoolCase {

    public static void main(String[] args) {

        LinkedBlockingQueue<Runnable> frThreadQueue = new LinkedBlockingQueue<Runnable>(5);
        ThreadPoolExecutor flExecutor = new ThreadPoolExecutor(1, 5, 0, TimeUnit.MILLISECONDS, frThreadQueue);

        for (int i = 0; i < 50; i++) {

            try {

                flExecutor.execute(new Runnable() {
                    @Override
                    public void run() {
                        System.out.println("启动线程。。。");

                        try {
                            Thread.sleep(3 * 1000);
                        } catch (InterruptedException e) {
                            e.printStackTrace();
                        }
                    }
                });
            } catch (Exception e) {
                e.printStackTrace();
            }
        }

    }
}
